<template>
    <view class="">
        <view class="p_20"  style="padding-bottom:140rpx">
            <view class="">
                <view class="f_s_24">{{infoData.bt}}</view>
                <view class="m_t_10 f_s_20 c_red ">{{infoData.money||'-'}}元/月</view>
                <view class="dis_f_l_c m_t_10 m_b_10">
                    <view class="dis_f_l_c"> <u-icon name="map"></u-icon> {{infoData.districts}}</view>
                    <view class="dis_f_l_c m_l_10 m_r_10"> <u-icon name="bag" size="20"></u-icon> {{infoData.jobBenefits}}</view>
                    <view class="dis_f_l_c"> <image src="@/static/img/xl.png" style="width: 40rpx;height: 40rpx;"></image> {{infoData.education}}</view>
                </view>
                <view class="c_o f_s_12 m_t_10">更新时间：{{infoData.createTime}}</view>
                <u-divider></u-divider>
            </view>
            <view class="card_box p_10 m_t_10">
<!--                <view class="dis_f_sb" v-if="infoData.sfnmName=='匿名'">
                    <view class="dis_f_l_c">
                        <u-avatar src="" size="50"></u-avatar>
                        <view class="m_l_10">
                            <view class=" m_b_5">匿名用户</view>
                            <view class="dis_f_l_c"  @click="handleToTel">
                                {{infoData.lxrDh}}
                            </view>
                        </view>
                    </view>
                </view>-->
                <view class="dis_f_sb">
                    <view class="dis_f_l_c">
                        <u-avatar :src="userData.wxAvatar" size="50"></u-avatar>
                        <view class="m_l_10">
                            <view class=" m_b_5">{{infoData.lxrXm}}</view>
                            <view class="dis_f_l_c">
                                {{infoData.enterpriseName}}
                            </view>
                        </view>
                    </view>
                </view>
            </view>
            <u-divider></u-divider>
            <view>
                <view class="f_s_18">职位福利</view>
                <view class="f_s_14 m_t_10">{{infoData.workExperience}}</view>
            </view>
            <u-divider></u-divider>
            <view class="card_box m_t_10">
                <view class="f_s_18">职位详情</view>
                <view class="f_s_14 m_t_10">{{infoData.nr}}</view>
            </view>
            <u-divider></u-divider>
            <view>
                <view class="f_s_18">工作地址</view>
                <view class="dis_f_l_c f_s_14 m_t_10"> <u-icon name="map"></u-icon> {{infoData.province}}{{infoData.city}}{{infoData.districts}}{{infoData.locationsName||''}}</view>
            </view>
            <u-divider></u-divider>
            <view class="jlq_box dis_f_sb_c p_10" @click="handlerToGroup">
                <view class="dis_f_l_c">
                    <image :src="groupData.url" style="width: 100rpx;height: 100rpx;"></image>
                    <view class="m_l_5">
                        <view class="f_s_20 f_w_b">{{groupData.configName}}</view>
                        <view class="f_s_14 m_t_5" style="color:#5FB7EB;">{{groupData.remark}}</view>
                    </view>
                </view>
                <u-icon name="arrow-right"></u-icon>
            </view>
            <u-divider></u-divider>
            <view>
                <view class="f_s_18 dis_f_l_c">
                    <u-icon name="warning-fill" color="#FF6B12" size="20"></u-icon>
                   <view class="m_l_10"> {{ safetyReminder.configName }}</view>
                </view>
                <view class="f_s_14 m_t_10 c_9">
                    {{safetyReminder.configValue}}
                <text style="color:#FF6B12;" @click="handleToIssue"> 立即举报 ></text>
                </view>
            </view>
            <u-divider></u-divider>
            <view class="f_s_18">您可能感兴趣</view>
            <view v-if="list.length>0">
                <s-enterprise :goodsList="list" @updateData="updateData"></s-enterprise>
            </view>
            <s-empty v-else/>
        </view>
        <view class="info_bottom dis_f_sb_c">
            <view class="dis_f_l_c">
                <view class="dis_f_co_c" @click="handleToIndex">
                    <image src="/static/tabs/home.png" style="width: 50rpx;height: 50rpx;"></image>
                    <view class="m_t_5 c_9 f_s_14">首页</view>
                </view>
                <view class="dis_f_co_c m_l_20">
                    <u-icon name="phone" size="25" @click="handleToTel"></u-icon>
                    <view class="m_t_5 c_9 f_s_14">电话</view>
                </view>
            </view>
            <view>
                <u-button type="error" @click="handleShowNotes">申请职位</u-button>
            </view>
        </view>
        <!-- 授权弹窗 -->
        <s-auth-modal />
    </view>
</template>

<script>
import {
    getListInfoApi,
    addCollectApi,
    delCollectApi,
    getByKeyApi,
    getMyInfoApi,
    resumeLibraryApi,
    getInformationListApi
} from "@/sheep/api";
import {myMixins} from "@/mixins/myMixins";

export default {
    mixins:[myMixins],
    name: "info",
    data() {
        return {
            getListInfoApi:{},
            src:'',
            swiperList: [],
            safetyReminder: {},
            groupData: {},
            infoData:{},
            userData:{},
            myInfoVo:{},
            queryData:{},
        }
    },
    onLoad(params) {
        this.goodsId = params.goodsId;
        this.queryData.id = params.goodsId
        // this.queryData.lat = uni.getStorageSync('latitude')
        // this.queryData.lot = uni.getStorageSync('longitude')
        this.getInfo()
        this.getMyInfo()
        this.getGroup()
        this.getsafetyReminder()
    },
    onShareAppMessage() {
        return {
            title: '['+this.infoData.typeName+']'+this.infoData.bt,
            imageUrl: this.swiperList[0],
            path: '/pages/index/index'
        }
    },
    methods:{
        getList(){
            console.log("this.queryObj", this.queryObj);
            this.queryObj.bt=this.userData.bt
            getInformationListApi(this.queryObj).then(res=>{
                this.list = this.list.concat(res.rows)
                this.total = res.total
                if (this.queryObj.pageNum*this.queryObj.pageSize<this.total){
                    this.status = 'loadmore'
                }else{
                    this.status = 'nomore'
                }
                uni.stopPullDownRefresh()
            })
        },
        handlerToGroup(){
            uni.navigateTo({
                url: "/pages/index/group",
            })
        },
        handleToIssue(){
            uni.navigateTo({
                url: '/pages/mine/addIssue'
            })
        },
        async getGroup() {
            let res = await getByKeyApi("group");
            this.groupData = res.data?.[0];
        },
        async getsafetyReminder() {
            let res = await getByKeyApi("safetyReminder");
            this.safetyReminder = res.data?.[0];
        },
        getMyInfo() {
            getMyInfoApi().then((res) => {
                this.myInfoVo = res.data;
            });
        },
        getInfo(){
            getListInfoApi(this.queryData).then(res=>{
                this.infoData=res.data.vo
                this.userData=res.data.user
                if (res.data.vo.photoUrl){
                    this.swiperList=res.data.vo.photoUrl.split(',')
                }
                if (res.code==200){
                    this.getList()
                }
            })
        },
        handleToTel(){
            uni.makePhoneCall({
                phoneNumber: this.infoData.lxrDh
            })

        },
        handleToIndex(){
            uni.switchTab({
                url: '/pages/index/index'
            });
        },
        handleLike(){
            if (this.infoData.sfxh){
                delCollectApi({inFormationId:this.infoData.id}).then(res=>{
                    uni.showToast({
                        title: res.msg,
                        icon: "none",
                        duration: 2000
                    });
                    if(res.code==200){
                        this.getInfo()
                    }
                })
            }else{
                addCollectApi({userIdPassivity:this.infoData.id}).then(res=>{
                    uni.showToast({
                        title: res.msg,
                        icon: "none",
                        duration: 2000
                    });
                    if(res.code==200){
                        this.getInfo()
                    }
                })
            }
        },
        handleShowNotes(){
            //查看pdf
           /* uni.navigateTo({
                url: '/pages/index/pdf?url='+this.userData.pdfUrl
            });*/
            //二次确认
            let that = this
            uni.showModal({
                title: '提示',
                content: '是否申请该职位',
                success: (res) => {
                    if (res.confirm) {
                        resumeLibraryApi({companyId:this.infoData.userId,businessInformationId:this.infoData.id}).then(res=>{
                            uni.showToast({
                                title: res.msg,
                                icon: "none",
                                duration: 2000
                            })
                        })
                    } else if (res.cancel) {
                        console.log('用户点击取消');
                    }
                }
            });
        }

    }
}
</script>

<style scoped lang="scss">
.info_bottom{
    position: fixed;
    bottom: 0;
    padding: 10rpx 50rpx 20rpx;
    width: calc(100% - 100rpx);
    background: #fff;
    border-top:1px solid #cccccc;
}
.jlq_box{
    //背景渐变
    background: linear-gradient(to right, #E7D4FF, #CFEFFE);
    border-radius: 10rpx;
}
</style>
